import request from './request.js'
import mockRequest from './mockRequest.js'
// 模块化发送请求  分装成一个函数
export const reqCategoryList = ()=>{
    return request({
        url:'/product/getBaseCategoryList',
        method:'get'
    })
}
export const reqGetBannerList = ()=>{
    return mockRequest({
        url:'/banner',
        method:'get'
    })
}
export const reqGetFloorList = ()=>{
    return mockRequest({
        url:'/floor',
        method:'get'
    })
}
export const reqGetSearchList = (data)=>{
    return request({
        url:'/list',
        method:'post',
        data
    })
}

export const reqGetDetailList = (skuId)=>{
    return request({
        url:`/item/${skuId}`,
        method:'get'
    })
}
// 加入购物车 /api/cart/addToCart/{ skuId }/{ skuNum }
export const reqAddOrUpdateShopCart = (skuId,skuNum)=>{
    return request({
        url:`/cart/addToCart/${ skuId }/${ skuNum }`,
        method:'post'
    })
}
// 结算页面的api 购物列表
export const reqShopCartList = ()=>{
    return request({
        url:'/cart/cartList',
        method:'get'
    })
}
// 删除的请求 /api/cart/deleteCart/{skuId}
export const reqDeleteCart = (skuId)=>{
    return request({
        url:`/cart/deleteCart/${skuId}`,
        method:'delete'
    })
}
// 切换商品选中的状态
// /api/cart/checkCart/{skuID}/{isChecked}
export const reqCheckCart = (skuId,isChecked)=>{
    return request({
        url:`/cart/checkCart/${skuId}/${isChecked}`,
        method:'get'
    })
}
// 获取验证码  /api/user/passport/sendCode/{phone}
export const reqSendCode = (phone) =>{
        return request({
            url:`/user/passport/sendCode/${phone}`,
            method:'get'
        })
}
// 注册用户接口/api/user/passport/register
export const reqRegister = (phone,code,password)=>{
        return request({
            url:'/user/passport/register',
            method:'post',
            data:{
                phone,
                code,
                password
            }
        })
}
// 用户登录/api/user/passport/login
export const reqLogin = (phone,password)=>{
    return request({
        url:'/user/passport/login',
        method:'post',
        data:{
            phone,
            password
        }
    })
}
// 获取用户信息/api/user/passport/auth/getUserInfo
export const reqUserInfo = ()=>{
    return request({
        url:'/user/passport/auth/getUserInfo',
        method:'get'
    })
}

// 退出登录 /api/user/passport/logout
export const reqlogout = ()=>{
    return request({
        url:'/user/passport/logout',
        method:'get'
    })
}
// /api/user/userAddress/auth/findUserAddressList
// 获取用户地址信息
// get
export const reqFindUserAddressList = ()=>{
    return request({
        url:'/user/userAddress/auth/findUserAddressList',
        method:'get'
    })
}
// 获取订单交易信息
// /api/order/auth/trade
export const reqTrade = ()=>{
    return request({
        url:'/order/auth/trade',
        method:'get'
    })
}
// 提交订单的请求地址
// /api/order/auth/submitOrder?tradeNo={tradeNo}
export const reqSubmitOrder = (tradeNo,data)=>{
    return request({
        url:`/order/auth/submitOrder?tradeNo=${tradeNo}`,
        method:'post',
        data
    })
}
// 获取订单的支付信息
// /api/payment/weixin/createNative/{orderId}
export const reqCreateNative = (orderId)=>{
    return request({
        url: `/payment/weixin/createNative/${orderId}`,
        method:'get'
    })
}
// 查询支付状态
// 判断用户是否支付成功
// /api/payment/weixin/queryPayStatus/{orderId}
export const reqOrderStatus = (orderId)=>{
        return request({
            url:`/payment/weixin/queryPayStatus/${orderId}`,
            method:'get'
        })
}
// 获取我的订单
// /api/order/auth/{page}/{limit}
// page  页码   limit  每页显示的数量
export const reqAuth = (page,limit)=>{
    return request({
        url:`/order/auth/${page}/${limit}`,
        method:'get'
    })
}